<template>
  <a-table
    ref="table"
    :columns="columns" :data-source="list" :scroll="{ x: 1500, y: 300 }"
           :rowKey="
           (record, index) => {
          return index;
        }
      "
           :loading="loading"
           :pagination="pagination"
           @change="this.getList"
           @showSizeChange="this.getList">
    <template slot="operation" slot-scope="text, record" >
    </template>
    <a-modal
      v-model="modalVisible"
      :title="modalTitle"
      width="1050px"
      @ok="submit"
      :maskClosable="false"
      :footer="isHideFoot?null:undefined"
    >
      <pay-channel-net-operation ref="modalForm"/>
    </a-modal>
  </a-table>
</template>
<script>


export default {
 data: function () {
    return {
      modalVisible:false,
      modalTitle:'',
      list: [],
      beanInfo: {},
      operatorType: "",
      loading: false,
      // preOne: "limitInfo",
      pagination: {
        pageSizeOptions: ["10", "20", "30", "40", "100"],
        defaultCurrent: 1,
        defaultPageSize: 10,
        showQuickJumper: true,
        showSizeChanger: true,
        showTotal: (total, range) =>
          `共 ${total} 条记录`,
      },
 columns: [
{ title: '任务名称', width: 150, dataIndex: 'taskName', key: 'taskName', fixed: 'left' },
{ title: '任务批次', width: 150, dataIndex: 'taskBatch', key: 'taskBatch', fixed: 'left' },
{ title: '任务描述', width: 150, dataIndex: 'taskDesc', key: 'taskDesc', fixed: 'left' },
{ title: '任务参数', width: 150, dataIndex: 'taskParam', key: 'taskParam', fixed: 'left' },
{ title: '任务优先级', width: 150, dataIndex: 'taskPrio', key: 'taskPrio', fixed: 'left' },
{ title: '重试时间间隔', width: 150, dataIndex: 'redoMTIV', key: 'redoMTIV', fixed: 'left' },
{ title: '最后检查时间', width: 150, dataIndex: 'lastChkTime', key: 'lastChkTime', fixed: 'left',
   formatter:function(cellvalue, options, rowObject){
		            	if(cellvalue!=null&&cellvalue!=""){
		            		var year =cellvalue.substr(0,4);
		            		var month =cellvalue.substr(4,2);
		            		var day =cellvalue.substr(6,2);
		            		var hour =cellvalue.substr(8,2);
		            		var minute =cellvalue.substr(10,2);

		            		return year+"-"+month+"-"+day+" "+hour+":"+minute+"";
		            	}
			            }},
{ title: '最后注册时间', width: 150, dataIndex: 'lastRegTime', key: 'lastRegTime', fixed: 'left',
   formatter:function(cellvalue, options, rowObject){
 		            	if(cellvalue!=null&&cellvalue!=""){
 		            		var year =cellvalue.substr(0,4);
 		            		var month =cellvalue.substr(4,2);
 		            		var day =cellvalue.substr(6,2);
 		            		var hour =cellvalue.substr(8,2);
 		            		var minute =cellvalue.substr(10,2);

 		            		return year+"-"+month+"-"+day+" "+hour+":"+minute+"";
 		            	}
 			       	}},
{
    title: '下次注册时间',
    dataIndex: 'nextRegTime',
    key: 'nextRegTime',
    fixed: 'left',
    width: 150,
      formatter:function(cellvalue, options, rowObject){
    		            	if(cellvalue!=null&&cellvalue!=""){
    		            		var year =cellvalue.substr(0,4);
    		            		var month =cellvalue.substr(4,2);
    		            		var day =cellvalue.substr(6,2);
    		            		var hour =cellvalue.substr(8,2);
    		            		var minute =cellvalue.substr(10,2);

    		            		return year+"-"+month+"-"+day+" "+hour+":"+minute+"";
    		            	}
    			            },
  },
   ],
    };
  },


  methods:{
    async getList() {
      this.list = [
        {
        },
      ];
      try {
        const res = await this.$get("/admin/batchtask/timingTasksList");
        this.list = res.data.content || {};
      } catch (e) {
        console.error(e);
      }
    },
    openModal(type = "edit", list) {
      this.modalTitle = {
        edit: "支付通道网络切换",
      }[type];
      this.modalVisible = true;
      this.$nextTick(() => {
        this.$refs.modalForm.setOperatorType(type);
        if (type === "edit") {
          this.$refs.modalForm.setBeanInfo(this.list);
        }
        this.$refs.modalForm.resetFields();
      });
    },
    async submit() {
      const res = await this.$refs.modalForm.submit();
      if (res) {
        this.modalVisible = false;
        this.pagination.defaultCurrent = 1;
        await this.getList();
      }
    },
    edit(record) {
      this.openModal("edit", record);
    },
  },
  created() {
    this.getList();
  },
};
</script>
